package com.jw.qme.socket.message;

import com.alibaba.fastjson.JSON;
import com.jw.qme.domain.po.Friend;
import org.springframework.stereotype.Component;

/**
 * ClassName: com.jw.qme.socket.message
 * Datetime: 2025/4/5 下午8:40
 * Description:
 *
 * @author 汪佳泉
 * @version 1.0
 * @since 1.0
 */
public class MessageFactory {

    public static Object getMessage(SocketMessage socketMessage1){
        Object socketMessage;
        if(0 == socketMessage1.getType()){
            socketMessage = JSON.parseObject(socketMessage1.getContent(), ChatMessage.class);
        } else if(1 == socketMessage1.getType()){
            socketMessage = JSON.parseObject(socketMessage1.getContent(), GroupMessage.class);
        } else if(2 == socketMessage1.getType()){
            socketMessage = JSON.parseObject(socketMessage1.getContent(), FriendMessage.class);
        } else if(4 == socketMessage1.getType()){
            socketMessage = JSON.parseObject(socketMessage1.getContent(), ChatMessage.class);
        } else {
            socketMessage = null;
        }
        return socketMessage;
    }

}
